using com.tc.assistance.protocol.entity;
using System.Collections.Generic;
using com.tc.assistance.entity.device;
using com.tc.assistance.parser;
using System.Xml;
using System.IO;
using com.tc.assistance.utils;

namespace com.tc.assistance.engine
{

    public class SoftDeviceController : AbstractController
    {
        GeneralDevice device;
        public string getDeviceId()
        {
            return device.getId();
        }

        public void setDeviceId(string deviceId)
        {
            this.device.setId(deviceId);
        }
        public override GeneralDevice getDevice() 
        {

            return device;
        }

        public SoftDeviceController()
        {

            Stream ind = new FileStream("config/softdevice.xml", FileMode.OpenOrCreate);
            device = ProtocolParser.parseDeviceDefination(ind);
            ind.Close();

            device.setId("0000");
            foreach (DeviceComponent dc in device.getComponents().Values)
                dc.setCurrentStatus("off");
        }

        public void commit()
        {
            Stream outd = new FileStream("config/softdevice.xml", FileMode.OpenOrCreate);
            ProtocolStreamer.streamDevice(outd, device);
            outd.Close();


        }



    }
}
